package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.business.domain.MealPlan;
import com.elder.business.domain.MealPlanDTO;
import com.elder.business.service.IMealPlanService;
import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author elder
 * @date 2024-03-11
 */
@RestController
@RequestMapping("/system/plan")
public class MealPlanController extends BaseController
{
    @Autowired
    private IMealPlanService mealPlanService;

    /**
     * 查询【请填写功能名称】列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String planTime,Integer pageNum,Integer pageSize)
    {
        return mealPlanService.selectMealPlanList(planTime,pageNum,pageSize);
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @Anonymous
    @GetMapping(value = "/{planId}")
    public AjaxResult getInfo(@PathVariable("planId") Long planId)
    {
        return success(mealPlanService.selectMealPlanByPlanId(planId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Anonymous
    @Log(title = "新增食谱", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MealPlanDTO mealPlan)
    {
        return toAjax(mealPlanService.insertMealPlan(mealPlan));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Anonymous
    @Log(title = "修改食谱", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MealPlanDTO mealPlan)
    {
        return toAjax(mealPlanService.updateMealPlan(mealPlan));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:plan:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planIds}")
    public AjaxResult remove(@PathVariable Long[] planIds)
    {
        return toAjax(mealPlanService.deleteMealPlanByPlanIds(planIds));
    }
}
